package com.thinkTank.oa.lucene;

import java.util.ArrayList;
import java.util.List;

public class SolrProject implements IsolrProject{
	//查询目标对象
	private final String target="project";
	//默认查询的字段
	private final String[] fieldList=new String[]{"projectType", "researchField", "projectName", "introduction", "keyWords","marketProspect"};
	@Override
	public boolean add(LuceneProject project) {
		List<LuceneProject> projectList=new ArrayList<LuceneProject>();
		projectList.add(project);
		return SolrUtils.add(target, projectList);
	}

	@Override
	public boolean update(LuceneProject project) {
		List<LuceneProject> projectList=new ArrayList<LuceneProject>();
		projectList.add(project);
		return SolrUtils.update(target, projectList);
	}

	@Override
	public boolean deleteById(String projectId) {
		List<String> ids=new ArrayList<String>();
		ids.add(projectId);
		return SolrUtils.delete(target, ids);
	}

	@Override
	public boolean addProjectList(List<LuceneProject> projectList) {
		return SolrUtils.add(target, projectList);
	}

	@Override
	public Pagination queryProjectList(String keyword, List<String> fields, int page, int size) {
		return SolrUtils.search(target, keyword,fields, page, size);

	}

	@Override
	public Pagination queryProjectList(String keyword, int page, int size) {
		List<String> fields=new ArrayList<String>();
		for (String string : fieldList) {
			fields.add(string);
		}
		return queryProjectList(keyword,fields, page, size);
	}
	

	@Override
	public Pagination relate(String keyword, int page, int size) {
		List<String> fields=new ArrayList<String>();
		for (String string : fieldList) {
			fields.add(string);
		}
		return SolrUtils.relate(target, keyword, fields, page, size);
	}

	@Override
	public Pagination relate(String keywords, List<String> fields, int pageNo, int pageSize) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Pagination queryProjectList(String keyword, List<String> fields, int page, int size, boolean flag) {
		// TODO Auto-generated method stub
		return SolrUtils.relate(target, keyword, fields, page, size);
		}

}
